//
//  FanInfoViewController.m
//  ForengnMenu
//
//  Created by @-@ on 16/1/23.
//  Copyright © 2016年 余旺. All rights reserved.
//

#import "FanInfoViewController.h"
#import "FanInfoTableViewCell.h"

@interface FanInfoViewController ()<UITableViewDataSource,UITableViewDelegate>

@property UIButton * button;


@end

@implementation FanInfoViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    self.fanInfoBGImageView.image = [UIImage imageNamed:@"fanInfoBG.jpg"];

    UIButton * rightBnt = [UIButton buttonWithType:UIButtonTypeCustom];
    rightBnt.frame = CGRectMake(0, 0, 60, 30);
    [rightBnt setImage:[UIImage imageNamed:@"iconfont-fanhui"] forState:UIControlStateNormal];
    [rightBnt setTitle:@"返回" forState:UIControlStateNormal];
    [rightBnt addTarget:self action:@selector(returnAction) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightBnt];
    



}
-(void)returnAction{
    
    [self.navigationController popViewControllerAnimated:YES];
    
}


//视图将要出现时
-(void)viewWillAppear:(BOOL)animated{
    
    //让导航栏透明
    [self.navigationController.navigationBar setBackgroundImage:[UIImage new] forBarMetrics:UIBarMetricsDefault];
    
    //让分割线透明
    [self.navigationController.navigationBar setShadowImage:[UIImage new]];
    
}

//当界面消失之前调用
- (void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    
    //让分割线不透明
    [self.navigationController.navigationBar setShadowImage:[UIImage imageNamed:@""]];
    
}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 4;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    if (section == 0) {
        return 1;
    }else{
        return 1;
    }
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 0) {
        return 130;
    }else{
        return 47;
    }
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    static NSString * identifier;
    if (indexPath.section == 0) {
        identifier = @"cell0";
        
    }else if(indexPath.section == 1){
        identifier = @"cell1";
    }else if (indexPath.section == 2){
        identifier = @"cell2";
        
    }else{
        identifier = @"cell3";
        
    }
    
    
    
    FanInfoTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    
    NSString * string = self.info[@"image"];
    cell.fanInfoImageView.image = [UIImage imageNamed:string];
    
    NSString * string1 = self.info[@"name"];
    cell.FanNameLabel.text = string1;
    //    self.title = self.info[@"name"];
    
    UILabel * l = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 80, 40)];
    l.text = self.info[@"name"];
    l.textAlignment = NSTextAlignmentCenter;
    l.textColor = [UIColor whiteColor];
    self.navigationItem.titleView = l;
    
    
    
    NSString * string2 = self.info[@"sex"];
    cell.fanSexLabel.text = string2;
    
    NSString * string3 = self.info[@"title"];
    cell.fanTitle1.text = string3;
    
    NSString * string4 = self.info[@"content"];
    cell.fanContent1.text = string4;
    
    NSString * string5 = self.info[@"title1"];
    cell.fanTitle2.text = string5;
    
    NSString * string6 = self.info[@"content1"];
    cell.fanContent2.text = string6;
    
    NSString * string7 = self.info[@"title2"];
    cell.fanTitle3.text = string7;
    
    NSString * string8 = self.info[@"content2"];
    cell.fanContent3.text = string8;
    
    
    self.button = (UIButton *)[cell viewWithTag:100];
    [self.button setTitle:@"关注" forState:UIControlStateNormal];
    
    //    cell.seeTitleLabel.text = self.titles[indexPath.row];
    //    cell.seeContentLabel.text = self.subTitles[indexPath.row];
    
    
    return cell;
    
}

//点击时触发
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    //取消选择状态
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}



/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
